# -*- coding: utf-8 -*-
# @Create_time   : :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :.py
# @Desc          :



from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from spmi_fee_domain.dwd.spmi_wide.dwd_spmi_fee_cost_apack import spmi_dwd__dwd_spmi_fee_cost_apack
from spmi_fee_domain.dwd.spmi_wide.dwd_spmi_fee_cost_operation import spmi_dwd__dwd_spmi_fee_cost_operation
from spmi_fee_domain.dwd.spmi_wide.dwd_spmi_fee_cost_piece import spmi_dwd__dwd_spmi_fee_cost_piece_006
from spmi_fee_domain.dwd.spmi_wide.dwd_spmi_fee_cost_piece import spmi_dwd__dwd_spmi_fee_cost_piece_other
from spmi_fee_domain.dwd.spmi_wide.dwd_spmi_fee_cost_transfer import spmi_dwd__dwd_spmi_fee_cost_transfer

spmi_dwd__dwd_spmi_fee_cost_wide_dt = SparkSqlOperator(
    task_id='spmi_dwd__dwd_spmi_fee_cost_wide_dt',
    email=['lukunmingn@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dwd__dwd_spmi_fee_cost_wide_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='spmi_fee_domain/dwd/spmi_wide/dwd_spmi_fee_cost_wide_dt/execute.sql',
    pool_slots=2,
    driver_cores=3,
    driver_memory='6G',
    executor_cores=4,
    executor_memory='10G',
    num_executors=110,
    conf={'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
          'spark.dynamicAllocation.maxExecutors': 130,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 300,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.executor.memoryOverhead': '2G',
          'spark.yarn.maxAppAttempts': 1,
          'spark.sql.shuffle.partitions': 1800,
          'spark.shuffle.memoryFraction': '0.5',
          # 'spark.shuffle.file.buffer': '64k',
          # 'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=5 -XX:ConcGCThreads=2',
          'spark.shuffle.consolidateFiles': 'true',
'spark.io.compression.codec': 'org.apache.spark.io.ZStdCompressionCodec'
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 300,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 300,  # 最大分区
              },
    yarn_queue='warehouse',
    execution_timeout=timedelta(hours=2),
    retries=0,
)

spmi_dwd__dwd_spmi_fee_cost_wide_dt << [
    spmi_dwd__dwd_spmi_fee_cost_apack,
    spmi_dwd__dwd_spmi_fee_cost_operation,
    spmi_dwd__dwd_spmi_fee_cost_piece_006,
    spmi_dwd__dwd_spmi_fee_cost_piece_other,
    spmi_dwd__dwd_spmi_fee_cost_transfer
]
